<?php

namespace app\lmsx\validate;
use think\Validate;
class User extends Validate
{
    //定义验证规则
    protected $rule = [
        'name|姓名' => 'require|max:30',
        'phone|手机号码' => 'require|regex:^1[3,5,6,7,8]{1}\d{9}$|unique:lmsx_user',
        'code|验证码' => 'require',
       // 'role|角色'  => 'require',
        'city|学校'  => 'require',

    ];

    //定义验证提示
    protected $message = [
        'name.max' => '姓名最多不超过30个字符',
        'phone.regex' => '手机号码错误',
        //'phone.unique'     => '该手机号码已绑定',
    ];

    //定义验证场景
    protected $scene = [
        'edit' => ['role'],
        'add'   =>['name','phone','code'],
    ];

}
